﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Contacts.Mail;

namespace Contacts
{
    public partial class ContactMessage : Form
    {
        DataGridView dgv;
        
        string jr;

        public ContactMessage(DataGridView grd_jr_cont)
        {
            InitializeComponent();
            dgv = grd_jr_cont;
        }

        public ContactMessage()
        {}

        private void ContactMessage_Load(object sender, EventArgs e)
        {
            jr_request.Visible = true;
            jr_request.BringToFront();
            tbo_jr_req.Visible = true;
            tbo_jr_req.BringToFront();
            send.Visible = true;
            send.BringToFront();
            cancel.Visible = true;
            cancel.BringToFront();
            tbo_jr_req.Focus();            
        }

        private void yes_Click(object sender, EventArgs e)
        {
            jr_yes_no.Hide();
            jr_yes_no.SendToBack();
            yes.Hide();
            yes.SendToBack();
            no.Hide();
            no.SendToBack();
            jr_request.Visible = true;
            jr_request.BringToFront();
            tbo_jr_req.Visible = true;
            tbo_jr_req.BringToFront();
            send.Visible = true;
            send.BringToFront();
            cancel.Visible = true;
            cancel.BringToFront();
            tbo_jr_req.Focus();
        }

        private void no_Click(object sender, EventArgs e)
        {
            int cr = dgv.CurrentRow.Index + 1;
            dgv.CancelEdit();
            dgv.EndEdit();
            dgv.CurrentCell = dgv.Rows[0].Cells[0];           
            this.Close();
        }

        private void send_Click(object sender, EventArgs e)
        {
            jr = tbo_jr_req.Text;
            Mail.mailman.sendmail("New Job Role Request", jr + Environment.NewLine);
            this.Close();           
        }

        private void cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }        
    }
}
